
// Open MoneySpinner Suite v1
// An open source business management software system written in Java and MySQL
// Recommended IDE is NetBeans IDE 7.0.1
// Support Web Site: http://www.milliscript.com
//
// Copyright (C) 2014, Abiodun Aremu, Ibadan/NIGERIA.
// Open MoneySpinner Suite is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package openmoneyspinnersuite;

/**
 *
 * @author Abiodun Aremu
 */

import javax.swing.*;
final class ViewEmployee extends javax.swing.JInternalFrame {

    Object[][] tableObject=new Object[][]{};
    Systems systems=new Systems();
    Thread processThread=new Thread();
    Thread titleThread=new Thread();
    String query="Employee";
    /** Creates new form ViewCredit */
    public ViewEmployee() {
        initComponents();
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            tableObject,
            new String [] {
                "Employee ID", "First Name", "Middle Name", "Last Name", "Date of Birth", "Bank", "Account Number", "Department", "Designation", "Appointment Date", "Resignation Date","Overtime Status","Salary Status", "Transaction Balance"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false,false,false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        /* Execute thread */
        processThread=new Thread(new Runnable() {
            public void run() {
            disableControls();
            refreshTable("");
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewItemThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jSplitPane1 = new javax.swing.JSplitPane();
        jScrollPane4 = new javax.swing.JScrollPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        picLabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jPhoneTextField = new javax.swing.JTextField();
        jZipTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jCityTextField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jStateTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jAddressTextArea = new javax.swing.JTextArea();
        jLabel6 = new javax.swing.JLabel();
        jCountryTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jRefreshButton = new javax.swing.JButton();
        jCancelButton = new javax.swing.JButton();
        jTitleTextField = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jSexTextField = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jStatusTextField = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jPreviewButton = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(openmoneyspinnersuite.OpenMS_Finance_App.class).getContext().getResourceMap(ViewEmployee.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setToolTipText(resourceMap.getString("Form.toolTipText")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setName("Form"); // NOI18N
        setVisible(true);

        jSplitPane1.setDividerLocation(200);
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane1.setName("jSplitPane1"); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jPanel3.setBackground(resourceMap.getColor("jPanel3.background")); // NOI18N
        jPanel3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setPreferredSize(new java.awt.Dimension(140, 160));

        picLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        picLabel.setIcon(resourceMap.getIcon("picLabel.icon")); // NOI18N
        picLabel.setName("picLabel"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(picLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(picLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jPhoneTextField.setEditable(false);
        jPhoneTextField.setText(resourceMap.getString("jPhoneTextField.text")); // NOI18N
        jPhoneTextField.setName("jPhoneTextField"); // NOI18N
        jPhoneTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPhoneTextFieldActionPerformed(evt);
            }
        });

        jZipTextField.setEditable(false);
        jZipTextField.setName("jZipTextField"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jCityTextField.setEditable(false);
        jCityTextField.setName("jCityTextField"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jStateTextField.setEditable(false);
        jStateTextField.setName("jStateTextField"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jAddressTextArea.setColumns(20);
        jAddressTextArea.setEditable(false);
        jAddressTextArea.setLineWrap(true);
        jAddressTextArea.setRows(5);
        jAddressTextArea.setWrapStyleWord(true);
        jAddressTextArea.setEnabled(false);
        jAddressTextArea.setName("jAddressTextArea"); // NOI18N
        jScrollPane2.setViewportView(jAddressTextArea);

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jCountryTextField.setEditable(false);
        jCountryTextField.setName("jCountryTextField"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jRefreshButton.setFont(resourceMap.getFont("jRefreshButton.font")); // NOI18N
        jRefreshButton.setIcon(resourceMap.getIcon("jRefreshButton.icon")); // NOI18N
        jRefreshButton.setText(resourceMap.getString("jRefreshButton.text")); // NOI18N
        jRefreshButton.setName("jRefreshButton"); // NOI18N
        jRefreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRefreshButtonActionPerformed(evt);
            }
        });

        jCancelButton.setFont(resourceMap.getFont("jCancelButton.font")); // NOI18N
        jCancelButton.setIcon(resourceMap.getIcon("jCancelButton.icon")); // NOI18N
        jCancelButton.setText(resourceMap.getString("jCancelButton.text")); // NOI18N
        jCancelButton.setName("jCancelButton"); // NOI18N
        jCancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCancelButtonActionPerformed(evt);
            }
        });

        jTitleTextField.setEditable(false);
        jTitleTextField.setName("jTitleTextField"); // NOI18N
        jTitleTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTitleTextFieldActionPerformed(evt);
            }
        });

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jSexTextField.setEditable(false);
        jSexTextField.setName("jSexTextField"); // NOI18N
        jSexTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jSexTextFieldActionPerformed(evt);
            }
        });

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jStatusTextField.setEditable(false);
        jStatusTextField.setName("jStatusTextField"); // NOI18N
        jStatusTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jStatusTextFieldActionPerformed(evt);
            }
        });

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jPreviewButton.setFont(resourceMap.getFont("jPreviewButton.font")); // NOI18N
        jPreviewButton.setText(resourceMap.getString("jPreviewButton.text")); // NOI18N
        jPreviewButton.setName("jPreviewButton"); // NOI18N
        jPreviewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPreviewButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTitleTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                            .addComponent(jStatusTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane2)
                            .addComponent(jSexTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE))))
                .addGap(62, 62, 62)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPhoneTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(jLabel2)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCountryTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                            .addComponent(jZipTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                            .addComponent(jStateTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                            .addComponent(jCityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(78, 78, 78)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jRefreshButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jCancelButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPreviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jCityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jStateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel7)
                                    .addComponent(jTitleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(9, 9, 9)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jStatusTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel9))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(9, 9, 9)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jZipTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2)
                                    .addComponent(jSexTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel8))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jCountryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel1))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jPhoneTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3)))
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE))
                                .addGap(17, 17, 17))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(42, 42, 42)))
                        .addGap(26, 26, 26))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(jPreviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jRefreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(5, 5, 5))
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(467, 467, 467))
        );

        jScrollPane4.setViewportView(jPanel2);

        jSplitPane1.setTopComponent(jScrollPane4);

        jScrollPane3.setEnabled(false);
        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Employee ID", "First Name", "Middle Name", "Last Name", "Date of Birth", "Bank", "Account Number", "Department", "Designation", "Merchant Balance", "Appointment Date", "Resignation Date", "Overtime Status", "Salary Status"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setName("jTable1"); // NOI18N
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jTable1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jTable1PropertyChange(evt);
            }
        });
        jScrollPane5.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("jTable1.columnModel.title4")); // NOI18N
        jTable1.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("jTable1.columnModel.title6")); // NOI18N
        jTable1.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("jTable1.columnModel.title5")); // NOI18N
        jTable1.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("jTable1.columnModel.title8")); // NOI18N
        jTable1.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("jTable1.columnModel.title11")); // NOI18N
        jTable1.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("jTable1.columnModel.title9")); // NOI18N
        jTable1.getColumnModel().getColumn(8).setHeaderValue(resourceMap.getString("jTable1.columnModel.title10")); // NOI18N
        jTable1.getColumnModel().getColumn(9).setHeaderValue(resourceMap.getString("jTable1.columnModel.title16")); // NOI18N
        jTable1.getColumnModel().getColumn(10).setHeaderValue(resourceMap.getString("jTable1.columnModel.title14")); // NOI18N
        jTable1.getColumnModel().getColumn(11).setHeaderValue(resourceMap.getString("jTable1.columnModel.title15")); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1216, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 1216, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 384, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE))
        );

        jScrollPane3.setViewportView(jPanel1);

        jSplitPane1.setBottomComponent(jScrollPane3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 980, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jPhoneTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPhoneTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPhoneTextFieldActionPerformed

    private void jCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCancelButtonActionPerformed

        if(processThread.isAlive())
        {
            try{
                processThread.stop();
                titleThread.stop();
                System.out.println("Threads successfully stopped.");
            }catch(Exception e){System.out.println("Thread stopping error: "+e);}
            this.setTitle("::. View Employee");
            enableControls();
        }
        else
        dispose();
    }//GEN-LAST:event_jCancelButtonActionPerformed

    private void jRefreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRefreshButtonActionPerformed
        
        /* Execute thread */
        processThread=new Thread(new Runnable() {
            public void run() {
            disableControls();
            refreshTable("");
            resetField();
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewEmployeeThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }//GEN-LAST:event_jRefreshButtonActionPerformed
    public Icon getImage(String imagePath)
    {
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(openmoneyspinnersuite.OpenMSApp.class).getContext().getResourceMap(ViewEmployee.class);
        Icon displayedImage=resourceMap.getIcon("picLabel.icon");
        Icon empImage=null;
        empImage=new ImageIcon(Configuration.employeeImageDirPath+imagePath+".jpg");
        if(empImage.getIconHeight()!=-1)
        {
            displayedImage=empImage;
        }
        System.out.println(Configuration.employeeImageDirPath+imagePath+".jpg");
        return displayedImage;
    }
    private void jTitleTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTitleTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTitleTextFieldActionPerformed

    private void jSexTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSexTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jSexTextFieldActionPerformed

    private void jStatusTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jStatusTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jStatusTextFieldActionPerformed

private void jPreviewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPreviewButtonActionPerformed

        processThread=new Thread(new Runnable() {
            public void run() {
                disableControls();
                java.lang.Runtime run=java.lang.Runtime.getRuntime();
                try
                {
                    NoteWriterProfile note=new NoteWriterProfile();
                    note.writeProfile("Employee",query,null,null,null,null);
                         
                    if(OpenMSApp.d==null)
                    {
                        OpenMSApp.d=new NoteViewer("Preview Employee Profile - ",Configuration.profileNotePath);
                        OpenMSApp.d.setVisible(true);
                    }
                    else if(OpenMSApp.d.isVisible()==false)
                    {
                        OpenMSApp.d=new NoteViewer("Preview Employee Profile - ",Configuration.profileNotePath);
                        OpenMSApp.d.setVisible(true);       
                    }
                    else{
                        OpenMSApp.d.setTitle("Preview Employee Profile ");
                        OpenMSApp.d.doTas(OpenMSApp.d.PROFILE_TABINDEX);
                        OpenMSApp.d.transferFocus();                
                    }
                }
                catch(Exception e)
                {
                    System.out.println("Error occur at ViewEmployee.jPreviewButtonActionPerformed ! "+e);
                }
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewEmployeeThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();


}//GEN-LAST:event_jPreviewButtonActionPerformed

private void jTable1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jTable1PropertyChange
        // TODO add your handling code here:
        int row;
        String employeeID;
        System.out.println("Table Property Change"+jTable1.getSelectedRow());
        if(jTable1.getSelectedRow()!=-1)
        {
            row=jTable1.getSelectedRow();
            System.out.println("Table Row Selected"+row);
            employeeID=jTable1.getValueAt(row,0).toString();
            String sex="";
            String empAddress=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "vAddress");
            String empCity=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cCity");
            String empState=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cState");
            String empCountryCode=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cCountryCode").trim();
            String empCountry=systems.getValue(OpenMSApp.Database_A, "Select * from Country where cCountryCode='"+empCountryCode+"'", "vCountryName");
            String empPhone=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cPhone");
            String empSex=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cSex");
            String empTitle=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cTitle");
            String empStatus=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cStatus");
            String empZip=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cZip");
            if(empSex.equalsIgnoreCase("M"))
            {
                sex="Male";
            }
            if(empSex.equalsIgnoreCase("F"))
            {
                sex="Female";
            }
            jTitleTextField.setText(empTitle);
            jStatusTextField.setText(empStatus);
            jSexTextField.setText(sex);
            jAddressTextArea.setText(empAddress);
            jCityTextField.setText(empCity);
            jStateTextField.setText(empState);
            jCountryTextField.setText(empCountry);
            jZipTextField.setText(empZip);
            jPhoneTextField.setText(empPhone);
            picLabel.setIcon(getImage(employeeID));
        }
}//GEN-LAST:event_jTable1PropertyChange

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:

        int row;
        String employeeID;
        System.out.println("Table Property Change"+jTable1.getSelectedRow());
        if(jTable1.getSelectedRow()!=-1)
        {
            row=jTable1.getSelectedRow();
            System.out.println("Table Row Selected"+row);
            employeeID=jTable1.getValueAt(row,0).toString();
            String sex="";
            String empAddress=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "vAddress");
            String empCity=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cCity");
            String empState=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cState");
            String empCountryCode=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cCountryCode").trim();
            String empCountry=systems.getValue(OpenMSApp.Database_A, "Select * from Country where cCountryCode='"+empCountryCode+"'", "vCountryName");
            String empPhone=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cPhone");
            String empSex=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cSex");
            String empTitle=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cTitle");
            String empStatus=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cStatus");
            String empZip=systems.getValue(OpenMSApp.Database_A, "Select * from employee where cEmployeeID='"+employeeID+"'", "cZip");
            if(empSex.equalsIgnoreCase("M"))
            {
                sex="Male";
            }
            if(empSex.equalsIgnoreCase("F"))
            {
                sex="Female";
            }
            jTitleTextField.setText(empTitle);
            jStatusTextField.setText(empStatus);
            jSexTextField.setText(sex);
            jAddressTextArea.setText(empAddress);
            jCityTextField.setText(empCity);
            jStateTextField.setText(empState);
            jCountryTextField.setText(empCountry);
            jZipTextField.setText(empZip);
            jPhoneTextField.setText(empPhone);
            picLabel.setIcon(getImage(employeeID));
        }
}//GEN-LAST:event_jTable1MouseClicked
                                                   
    void print()
    {
        try
        {
            jTable1.print();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    void resetField()
    {
        jTitleTextField.setText("");
        jStatusTextField.setText("");
        jSexTextField.setText("");
        jAddressTextArea.setText("");
        jCityTextField.setText("");
        jStateTextField.setText("");
        jCountryTextField.setText("");
        jZipTextField.setText("");
        jPhoneTextField.setText("");
        picLabel.setIcon(getImage(""));
    }
     private void disableControls()
    {
        jRefreshButton.setEnabled(false);
        jPreviewButton.setEnabled(false);
    }                                             
    private void enableControls()
    {
        jRefreshButton.setEnabled(true);
        jPreviewButton.setEnabled(true);
        this.setTitle("::. View Employee");
    }
    
    private void setProcessingTitle(Thread thread)
    {
        try{
            this.setTitle("::. View Employee - Processing Request");
            thread.sleep(500);
            this.setTitle("::. View Employee - Processing Request.");
            thread.sleep(500);
            this.setTitle("::. View Employee - Processing Request..");
            thread.sleep(500);
            this.setTitle("::. View Employee - Processing Request...");
            thread.sleep(500);
        }catch(Exception e){System.out.println("Title thread"+e);}
    }
    void refreshTable(String searchPara)
    {
            query="Employee";
            String[] dbEmployeeID=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",1);
            String[] dbFirstName=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",2);
            String[] dbLastName=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",4);
            String[] dbMiddleName=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",3);
            java.sql.Date[] dbDOB=systems.getTableDateArrayNum(OpenMSApp.Database_A, "Employee",13);
            String[] dbBankCode=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",17);
            String[] dbAccount=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",18);
            String[] dbDepartment=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee", 15);
            String[] dbDesignation=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",16);
            String[] dbBalance=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",19);
            java.sql.Date[] dbAppointmentDate=systems.getTableDateArrayNum(OpenMSApp.Database_A, "Employee",21);
            java.sql.Date[] dbResignationDate=systems.getTableDateArrayNum(OpenMSApp.Database_A, "Employee",22);
            String[] dbOvertimeStatus=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",23);
            String[] dbSalaryStatus=systems.getTableDataArrayNum(OpenMSApp.Database_A, "Employee",24);

            if(searchPara.isEmpty()==false)
            {
                String multipleSearch[]=searchPara.split(",");
                String queryPara="where (cEmployeeID = '"+multipleSearch[0]+"') or (vFirstName = '"+multipleSearch[0]+"')  or (vMiddleName = '"+multipleSearch[0]+"')  or (vLastName = '"+multipleSearch[0]+"') or (cPhone = '"+multipleSearch[0]+"') ";

                for(int k=1;k<multipleSearch.length;k++)
                {
                    queryPara+=" or (cEmployeeID like '%"+multipleSearch[k]+"%') or (vFirstName like '%"+multipleSearch[k]+"%') or (vMiddleName like '%"+multipleSearch[k]+"%')  or (vLastName like '%"+multipleSearch[k]+"%')  or (cPhone like '%"+multipleSearch[k]+"%') ";
                }

                dbEmployeeID=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 1);
                dbFirstName=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 2);
                dbLastName=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 4);
                dbMiddleName=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 3);
                dbDOB=systems.getDateColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 13);
                dbBankCode=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 17);
                dbAccount=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 18);
                dbDepartment=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 15);
                dbDesignation=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 16);
                dbBalance=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 19);
                dbAppointmentDate=systems.getDateColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 21);
                dbResignationDate=systems.getDateColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 22);
                dbOvertimeStatus=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 23);
                dbSalaryStatus=systems.getColumn(OpenMSApp.Database_A, "Select * from Employee "+queryPara, 24);
                query="Employee "+queryPara;
            }

        int x=0;
        int y=dbEmployeeID.length;

        tableObject=new Object[y][14];

        while(x<y)
        {
            if(dbOvertimeStatus[x]==null)
            {
                dbOvertimeStatus[x]="N/A";
            }
            if(dbSalaryStatus[x]==null)
            {
                dbSalaryStatus[x]="N/A";
            }
            String bankName=systems.getValue(OpenMSApp.Database_A, "Select * from Bank Where cBankCode='"+dbBankCode[x]+"'", "vName");
            String departmetName=systems.getValue(OpenMSApp.Database_A, "Select * from Department Where cDepartmentCode='"+dbDepartment[x]+"'", "vDepartmentName");
            String designationName=systems.getValue(OpenMSApp.Database_A, "Select * from Designation Where cDesignationCode='"+dbDesignation[x]+"'", "vDesignationName");
            tableObject[x][0]=dbEmployeeID[x];
            tableObject[x][1]=dbFirstName[x].trim();
            tableObject[x][2]=dbMiddleName[x].trim();
            tableObject[x][3]=dbLastName[x].trim();
            tableObject[x][4]=systems.extractSQLDate(dbDOB[x]);
            tableObject[x][5]=bankName.trim();
            tableObject[x][6]=dbAccount[x].trim();
            tableObject[x][7]=departmetName.trim();
            tableObject[x][8]=designationName.trim();
            
            tableObject[x][9]=systems.extractSQLDate(dbAppointmentDate[x]);

            if(dbResignationDate[x]==null)
            {
                tableObject[x][10]="N/A";
            }
            else
            {
                tableObject[x][10]=systems.extractSQLDate(dbResignationDate[x]);
            }
            System.out.println(dbAppointmentDate[x]+" =Apt & Rsg= "+dbResignationDate[x]);
            tableObject[x][11]=dbOvertimeStatus[x].trim();
            tableObject[x][12]=dbSalaryStatus[x].trim();
            try
            {
                tableObject[x][13]=systems.converToRealMoneyFormat(dbBalance[x].trim());
            }
            catch(Exception e)
            {
                tableObject[x][13]="Er!M1C01K0";
            }
            systems.freeHeap();
            x+=1;
            if(x==y){break;}
       }

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            tableObject,
            new String [] {
                "Employee ID", "First Name", "Middle Name", "Last Name", "Date of Birth", "Bank", "Account Number", "Department", "Designation", "Appointment Date", "Resignation Date","Overtime Status","Salary Status", "Transaction Balance"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false,false,false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        resetField();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea jAddressTextArea;
    private javax.swing.JButton jCancelButton;
    private javax.swing.JTextField jCityTextField;
    private javax.swing.JTextField jCountryTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField jPhoneTextField;
    private javax.swing.JButton jPreviewButton;
    private javax.swing.JButton jRefreshButton;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTextField jSexTextField;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTextField jStateTextField;
    private javax.swing.JTextField jStatusTextField;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTitleTextField;
    private javax.swing.JTextField jZipTextField;
    private javax.swing.JLabel picLabel;
    // End of variables declaration//GEN-END:variables

}
